<template>
  <div class="login_inner">
  </div>
</template>

<script>
import {innerAccessSign} from "../methods/request"
import {getOpenId} from "../methods/baseinfo.js"
export default {
  name: 'login_inner',
  data () {
    return {
      msg: ''
    }
  },
  created() {
    this.checkData();
  },
  methods:{
   hrefObj() {
      var localhref = window.location.href;
      var localarr = localhref.split('?')[1].split('&');
      // console.log(localarr)
      var tempObj = {};
      for (var i = 0; i < localarr.length; i++) {
        　tempObj[localarr[i].split('=')[0]] = localarr[i].split('=')[1];
      }
      return tempObj;
    },
    async checkData(){
          var hrefObj = this.hrefObj();
          var state = hrefObj.state.replace(/([^#]+)$/, "").replace("#", "");
          const openId = await getOpenId();
          // console.log(state)
         innerAccessSign({"userId":openId,"innerNo":state}).then(
                response => {
                  console.log(response)
                    var obj = Object.assign({}, response.data)
                        if(response.rspCode=="0000"){
                            localStorage.setItem("token",obj.sessionId)
                            sessionStorage.setItem("colour",obj.colour)
                            sessionStorage.setItem("logourl",obj.logoPicUrl)
                            sessionStorage.setItem("institutionName",obj.institutionName||"")
                            sessionStorage.setItem('isHkb',"2");
                            this.$router.push({
                                    path:"/",
                                    query:{
                                    }
                             })
                        }
                }).catch(
                    error => console.log(error)
                );
     
    }  
  }
}
</script>

<style scoped>

</style>
